/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef AVANT_SETTINGS_H
#define AVANT_SETTINGS_H
/*
* Avant dimensions and settings
* units are meters and kilograms
*/

//central chassis dimensions
#define CENTRAL_CHASSIS_LENGTH 0.95
#define CENTRAL_CHASSIS_HEIGHT 0.36
#define CENTRAL_CHASSIS_WIDTH 0.70
#define CENTRAL_CHASSIS_VOLUME (CENTRAL_CHASSIS_LENGTH*CENTRAL_CHASSIS_HEIGHT*CENTRAL_CHASSIS_WIDTH)

//rear chassis dimensions
#define REAR_CHASSIS_LENGTH 0.69
#define REAR_CHASSIS_HEIGHT 0.65
#define REAR_CHASSIS_WIDTH 0.70
#define REAR_CHASSIS_VOLUME (REAR_CHASSIS_LENGTH*REAR_CHASSIS_HEIGHT*REAR_CHASSIS_WIDTH)

//upper chassis dimensions
#define UPPER_CHASSIS_LENGTH 0.663
#define UPPER_CHASSIS_HEIGHT 0.20
#define UPPER_CHASSIS_WIDTH 0.40
#define UPPER_CHASSIS_VOLUME (UPPER_CHASSIS_LENGTH*UPPER_CHASSIS_HEIGHT*UPPER_CHASSIS_WIDTH)

//total hull volume
#define TOTAL_CHASSIS_VOLUME (REAR_CHASSIS_VOLUME+CENTRAL_CHASSIS_VOLUME+UPPER_CHASSIS_VOLUME)

//bottom upper boom dimensions
#define BOTTOM_UPPER_BOOM_LENGTH 1.10
#define BOTTOM_UPPER_BOOM_HEIGHT 0.04
#define BOTTOM_UPPER_BOOM_WIDTH 0.20
#define BOTTOM_UPPER_BOOM_VOLUME (BOTTOM_UPPER_BOOM_LENGTH*BOTTOM_UPPER_BOOM_HEIGHT*BOTTOM_UPPER_BOOM_WIDTH)

//top upper boom dimensions
#define TOP_UPPER_BOOM_LENGTH 1.10
#define TOP_UPPER_BOOM_HEIGHT 0.02
#define TOP_UPPER_BOOM_WIDTH 0.20
#define TOP_UPPER_BOOM_VOLUME (TOP_UPPER_BOOM_LENGTH*TOP_UPPER_BOOM_HEIGHT*TOP_UPPER_BOOM_WIDTH)

//joint gap between boom end and scoop
#define SCOOP_JOINT_DIAMETER 0.05

//lower boom dimensions
#define LOWER_BOOM_LENGTH (1.37-SCOOP_JOINT_DIAMETER/2-0.20)
#define LOWER_BOOM_HEIGHT 0.06
#define LOWER_BOOM_WIDTH 0.15
#define LOWER_BOOM_VOLUME (LOWER_BOOM_LENGTH*LOWER_BOOM_HEIGHT*LOWER_BOOM_WIDTH)

//total boom volume
#define TOTAL_BOOM_VOLUME (BOTTOM_UPPER_BOOM_VOLUME+TOP_UPPER_BOOM_VOLUME+LOWER_BOOM_VOLUME)

//total body volume; body = chassis + boom
#define TOTAL_BODY_VOLUME (TOTAL_CHASSIS_VOLUME + TOTAL_BOOM_VOLUME)

//scoop back dimensions
#define SCOOP_BACK_LENGTH 0.05
#define SCOOP_BACK_HEIGHT 0.40
#define SCOOP_BACK_WIDTH 1.00
#define SCOOP_BACK_VOLUME (SCOOP_BACK_LENGTH*SCOOP_BACK_HEIGHT*SCOOP_BACK_WIDTH)

//scoop blade dimensions
#define SCOOP_BOTTOM_LENGTH 0.40
#define SCOOP_BOTTOM_HEIGHT 0.01
#define SCOOP_BOTTOM_WIDTH 1.00
#define SCOOP_BOTTOM_VOLUME (SCOOP_BOTTOM_LENGTH*SCOOP_BOTTOM_HEIGHT*SCOOP_BOTTOM_WIDTH)

//cutting edge dimensions
#define CUTTING_EDGE_LENGTH 0.10
#define CUTTING_EDGE_HEIGHT 0.01
#define CUTTING_EDGE_WIDTH 1.00
#define CUTTING_EDGE_VOLUME (CUTTING_EDGE_LENGTH*CUTTING_EDGE_HEIGHT*CUTTING_EDGE_WIDTH)

//total scoop volume
#define TOTAL_SCOOP_VOLUME (SCOOP_BACK_VOLUME+SCOOP_BOTTOM_VOLUME+CUTTING_EDGE_VOLUME)

//mass
//#define CENTRAL_CHASSIS_MASS (TOTAL_BODY_MASS*CENTRAL_CHASSIS_VOLUME/TOTAL_BODY_VOLUME)
//#define REAR_CHASSIS_MASS (TOTAL_BODY_MASS*REAR_CHASSIS_VOLUME/TOTAL_BODY_VOLUME)
//#define UPPER_CHASSIS_MASS (TOTAL_BODY_MASS*UPPER_CHASSIS_VOLUME/TOTAL_BODY_VOLUME)
#define CENTRAL_CHASSIS_MASS 400
#define REAR_CHASSIS_MASS 100
#define UPPER_CHASSIS_MASS 100


//#define BOTTOM_UPPER_BOOM_MASS (TOTAL_BODY_MASS*BOTTOM_UPPER_BOOM_VOLUME/TOTAL_BODY_VOLUME)
//#define TOP_UPPER_BOOM_MASS (TOTAL_BODY_MASS*TOP_UPPER_BOOM_VOLUME/TOTAL_BODY_VOLUME)
//#define LOWER_BOOM_MASS (TOTAL_BODY_MASS*LOWER_BOOM_VOLUME/TOTAL_BODY_VOLUME)
#define BOTTOM_UPPER_BOOM_MASS 10
#define TOP_UPPER_BOOM_MASS 10
#define LOWER_BOOM_MASS 15
#define TOTAL_BOOM_MASS (BOTTOM_UPPER_BOOM_MASS + TOP_UPPER_BOOM_MASS + LOWER_BOOM_MASS)


#define SCOOP_BACK_MASS 15
#define SCOOP_BOTTOM_MASS 15
#define CUTTING_EDGE_MASS 5
#define TOTAL_SCOOP_MASS (SCOOP_BACK_MASS+SCOOP_BOTTOM_MASS+CUTTING_EDGE_MASS)

#define WHEEL_MASS 20.0

//distance from ground to the base of the hull
#define GROUND_CLEARANCE 0.20

//wheels
#define WHEEL_RADIUS 0.30
#define WHEEL_WIDTH 0.20

//reference point is centre of wheelbase at axle level

//wheel positions from reference point
#define WHEEL_X (CENTRAL_CHASSIS_WIDTH/2.0+WHEEL_WIDTH/2.0+0.02)
#define FRONT_WHEEL_Z 0.4//0.7
#define REAR_WHEEL_Z -0.4//-0.3//-0.1
#define WHEELBASE (2.0*WHEEL_X)

//central chassis position from reference point
#define CENTRAL_CHASSIS_Z -0.07
#define CENTRAL_CHASSIS_Y 0.08

//rear chassis position from reference point
#define REAR_CHASSIS_Z (CENTRAL_CHASSIS_Z-CENTRAL_CHASSIS_LENGTH/2-REAR_CHASSIS_LENGTH/2-0.01)
#define REAR_CHASSIS_Y (REAR_CHASSIS_HEIGHT/2)

//upper chassis position from reference point
#define UPPER_CHASSIS_Z -0.06
#define UPPER_CHASSIS_Y (CENTRAL_CHASSIS_Y+0.50)

//bottom upper boom position from reference point
#define BOTTOM_UPPER_BOOM_Z 0.16
#define BOTTOM_UPPER_BOOM_Y (CENTRAL_CHASSIS_Y+0.46)

//top upper boom position from reference point
#define TOP_UPPER_BOOM_Z 0.24
#define TOP_UPPER_BOOM_Y (CENTRAL_CHASSIS_Y+0.54)

//lower boom position from reference point
#define LOWER_BOOM_Z 0.36
#define LOWER_BOOM_Y (CENTRAL_CHASSIS_Y+0.34)

//scoop back position from reference point
#define SCOOP_BACK_Z 0.84
#define SCOOP_BACK_Y (CENTRAL_CHASSIS_Y-0.09)

//scoop blade position from reference point
#define SCOOP_BOTTOM_Z 1.04
#define SCOOP_BOTTOM_Y (CENTRAL_CHASSIS_Y-0.3)

//scoop blade position from reference point
#define CUTTING_EDGE_Z 1.295
#define CUTTING_EDGE_Y (CENTRAL_CHASSIS_Y-0.3)

//laser scanner position
#define SCANNER_OFFSET_Z 2.0
#define SCANNER_OFFSET_X 0

//other settings
#define MAX_MOTOR_SPEED 4.0 // m/s
#define MAX_MOTOR_TORQUE (9.81*770.0/4.0) //avant 320s max thrust force is 770 kp (kilogram-force, kilopond)

#define AXLE_FRICTION_TORQUE 1.0

#define MAX_BOOM_TORQUE 5000 // Nm (Newton metres)
#define MAX_TELESCOPE_FORCE 2000 // N (Newtons)	
#define MAX_SCOOP_TORQUE 1000 // Nm (Newton metres)

//how often sensor data is sent
#define LASER_INTERVAL 0.125
#define POSITION_INTERVAL 0.05

#endif //AVANT_SETTINGS_H
